﻿using LeaRun.Application.Entity.AppManage;
using LeaRun.Application.IService.AppManage;
using LeaRun.Application.Service.AppManage;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace LeaRun.Application.Busines.AppManage
{

    public class App_ProjectBLL
    {
        private App_ProjectIService service = new App_ProjectService();
        public App_ProjectEntity GetEntity(string keyValue)
        {
            return this.service.GetEntity(keyValue);
        }
        public void DownFile(string filename)
        {
            FileInfo fileInfo = new FileInfo(HttpContext.Current.Server.MapPath("/templates/" + filename + ".zip"));
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Charset = "GB2312";
            HttpContext.Current.Response.ContentEncoding = Encoding.Default;
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + fileInfo.Name);
            HttpContext.Current.Response.AddHeader("Content-Length", fileInfo.Length.ToString());
            HttpContext.Current.Response.WriteFile(fileInfo.FullName);
            HttpContext.Current.Response.End();
        }
        public IEnumerable<App_ProjectEntity> GetList(string queryJson)
        {
            return this.service.GetList(queryJson);
        }
        public void RemoveForm(string keyValue)
        {
            try
            {
                this.service.RemoveForm(keyValue);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void SaveForm(string keyValue, App_ProjectEntity entity, List<App_TemplatesEntity> entryList)
        {
            try
            {
                this.service.SaveForm(keyValue, entity, entryList);
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
